package com.nativetalk.controller.app.three.live;

import com.nativetalk.base.Page;
import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.TdNtLikes;
import com.nativetalk.bean.TdNtLiveComment;
import com.nativetalk.bean.live.TdNtLiveCourseHisUpdate;
import com.nativetalk.bean.live.TdNtLiveStudyInsert;
import com.nativetalk.bean.member.TdNtMember;
import com.nativetalk.bean.teacher.TdNtTeacherResult;
import com.nativetalk.common.Constants;
import com.nativetalk.common.Lang;
import com.nativetalk.common.util.JsonUtil;
import com.nativetalk.common.util.MemcachedUtils;
import com.nativetalk.service.live.update.LiveUpdateService;
import com.nativetalk.service.three.live.comment.LiveCommentService;
import com.nativetalk.service.three.live.insert.ThreeLiveInsertService;
import com.nativetalk.service.three.live.likes.LikesService;
import com.nativetalk.service.three.live.search.ThreeLiveSearchService;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by lizhun on 15/12/9.
 */
@Controller
public class ThreeLiveController {
    private static Logger logger = Logger.getLogger(ThreeLiveController.class);
    @Resource
    private ThreeLiveSearchService threeLiveSearchService;
    @Resource
    private LiveUpdateService liveUpdateService;
    @Resource
    private ThreeLiveInsertService threeLiveInsertService;
    @Resource
    private LiveCommentService liveCommentService;
    @Resource
    private LikesService likesService;
    /**
     * @return RetInfo
     * @Purpose 查找直播详情
     * @version 3.0
     * @time    2015-05-16
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/live/his/detail", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo detail(@RequestBody Map<String,Integer> map,
                          @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            //校验token，如果校验通过就从缓存中读取Member
            if (StringUtils.isBlank(token)) {
                RetInfo retInfo = RetInfo.getClientErrorInfo("Parameter token  is required");
                logger.info(JsonUtil.toJson(retInfo));
                return retInfo;
            }
            Object o = MemcachedUtils.get(token);
            if (o == null) {
                RetInfo retInfo = RetInfo.getReloginInfo(Lang.ZH);
                logger.info("缓存中没有MemberToken:[" + token + "]，用户需要重新登录系统。 retInfo-->" + JsonUtil.toJson(retInfo));
                return retInfo;
            }

            if (!TdNtMember.class.isInstance(o)) {
                RetInfo retInfo = RetInfo.getReloginInfo(Lang.ZH);
                logger.info("缓存的token不是TdNtMember类型:[" + token + "]，用户需要重新登录系统。 retInfo-->" + JsonUtil.toJson(retInfo));
                return retInfo;
            }
            TdNtMember tdNtMember = (TdNtMember) o;

            RetInfo retInfo = threeLiveSearchService.findLiveDetail(map.get("live_cou_his_id"), tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    /**
     * @return RetInfo
     * @Purpose 查找用户直播人气贡献排行榜
     * @version 3.0
     * @time    2015-05-16
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/live/his/popularity/Ranking", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo Ranking(@RequestBody Page page,
                           @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            retInfo = threeLiveSearchService.findLiveHisRanking(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找用户待直播或已购买直播记录
     * @version 3.0
     * @time    2015-05-16
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/token/live/his/member/list/unfinished", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo unfinished(@RequestBody Page page,
                              @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            page.setObj(tdNtMember.getMemb_id());
            retInfo = threeLiveSearchService.findLiveHisUnFinishByMembId(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 已完成直播
     * @version 3.0
     * @time    2015-05-16
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/token/live/his/member/list/finished", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo finished(@RequestBody Page page,
                            @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            page.setObj(tdNtMember.getMemb_id());
            retInfo = threeLiveSearchService.findLiveHisFinishByMembId(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 获取每小时直播费用
     * @version 3.0
     * @time    2015-05-16
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/teatoken/live/minAmount", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo minAmount() {
        RetInfo retInfo = new RetInfo();
        retInfo.setMark("0");
        retInfo.setTip("获取数据成功");
        retInfo.setObj(14);
        return retInfo;
    }
    /**
     * @return RetInfo
     * @Purpose  结束直播
     * @version 2.1
     * @time 2016-05-22
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/teatoken/teacher/live/his/end", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo end(@RequestBody TdNtLiveCourseHisUpdate tdNtLiveCourseHisUpdate,
                       @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtLiveCourseHisUpdate));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            tdNtLiveCourseHisUpdate.setTea_id(tdNtTeacherResult.getTea_id());
            retInfo = liveUpdateService.end(tdNtLiveCourseHisUpdate);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose  结束直播
     * @version 3.0
     * @time 2016-05-22
     * @author lizhun
     */
    @RequestMapping(value = "/app/6/token/member/live/his/end", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo endmember(@RequestBody TdNtLiveCourseHisUpdate tdNtLiveCourseHisUpdate) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtLiveCourseHisUpdate));

            RetInfo retInfo;
            retInfo = liveUpdateService.end(tdNtLiveCourseHisUpdate);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 购买直播
     * @version 2.1
     * @time    2015-05-16
     * @author lizhun
     */
    @RequestMapping(value = "/app/7/token/live/his/buy", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo buy(HttpServletRequest request, @RequestBody Map<String, String> map,
                       @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            TdNtLiveStudyInsert tdNtLiveStudyInsert = new TdNtLiveStudyInsert();
            tdNtLiveStudyInsert.setLive_cou_his_id(Integer.valueOf(map.get("live_cou_his_id")));
            tdNtLiveStudyInsert.setMemb_id(tdNtMember.getMemb_id());
            retInfo = threeLiveInsertService.addLive(tdNtLiveStudyInsert);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return  RetInfo
     * @Purpose 学生根据老师id查看老师直播
     * @version 3.2
     * @time    2015-08-24
     * @author lizhun
     */
    @RequestMapping(value = "/app/8/live/his/list", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo list(HttpServletRequest request, @RequestBody Page page,
                        @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHisListByTeaId(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 添加直播评论
     * @version 3.3
     * @time    2016-09-27
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/comment", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo comment(@RequestBody TdNtLiveComment tdNtLiveComment,
                           @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtLiveComment));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            tdNtLiveComment.setMemb_id(tdNtMember.getMemb_id());
            retInfo = liveCommentService.insertLiveComment(tdNtLiveComment);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 点赞或取消点赞
     * @version 3.3
     * @time    2016-09-27
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/likes", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo likes(@RequestBody TdNtLikes tdNtLikes,
                         @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtLikes));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            tdNtLikes.setMemb_id(tdNtMember.getMemb_id());
            retInfo = likesService.liveLikes(tdNtLikes);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找所有直播
     * @version 3.3
     * @time    2016-09-27
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/all", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo all(@RequestBody Page page,
                       @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            page.setObj(Constants.FindLiveType.all);
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHis(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找所有精选直播
     * @version 3.3
     * @time    2016-09-28
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/selection", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo selection(@RequestBody Page page,
                             @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            page.setObj(1);
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHis(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找所有热门直播
     * @version 3.3
     * @time    2016-09-28
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/hot", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo hot(@RequestBody Page page,
                       @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            page.setObj(Constants.FindLiveType.hot);
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHis(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 分类查找所有直播
     * @version 3.3
     * @time    2016-09-28
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/category", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo category(@RequestBody Page page,
                            @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            page.setObj(Constants.FindLiveType.category);
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHis(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找已购直播
     * @version 3.3
     * @time    2016-09-28
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/token/live/his/me", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo me(@RequestBody Page page,
                      @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            page.setObj(Constants.FindLiveType.purchased);
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            page.setDict_id(tdNtMember.getMemb_id());
            retInfo = threeLiveSearchService.findLiveHis(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找回放直播
     * @version 3.3
     * @time    2016-09-28
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/finish", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo finish(@RequestBody Page page,
                          @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHisByState(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找直播详情
     * @version 3.3
     * @time    2016-10-07
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/detail", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo detail9(@RequestBody Map<String,Integer> map,
                           @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            TdNtMember tdNtMember = null;
            //学生不等了也可以查看直播详情
            if (!StringUtils.isBlank(token)) {
                Object o = MemcachedUtils.get(token);
                if (o != null && TdNtMember.class.isInstance(o)) {
                    tdNtMember = (TdNtMember) o;
                }
            }

            RetInfo retInfo = threeLiveSearchService.findLiveDetailThree(map.get("live_cou_his_id"), tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找直播评论列表
     * @version 3.3
     * @time    2016-10-07
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/comment/list", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo comment(@RequestBody Page page,
                           @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            retInfo = liveCommentService.list(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找直播点赞列表
     * @version 3.3
     * @time    2016-10-07
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/likes/list", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo likes(@RequestBody Page page,
                         @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            retInfo = likesService.list(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
    /**
     * @return RetInfo
     * @Purpose 查找教师直播列表
     * @version 3.3
     * @time    2016-09-28
     * @author lizhun
     */
    @RequestMapping(value = "/app/9/live/his/teacher/list", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo teacher(@RequestBody Page page,
                           @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            page.setObj(6);
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = threeLiveSearchService.findLiveHis(page, tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
}



